"""
@name : 10.魔术方法
@author : wenyao
@projectname: sanchuanglianxi
"""
#__del__  、 __call__
# class A:
#     def __del__(self):
#         print("delete  myself")
#         del self
#
#     def __call__(self,name,age):
#         print(f"my name is {name}, my age is {age}")
#
#         print("i am call")
#
# a = A()
# b = A()
# print("xxxxxxxxxxxxxxxxxxxxx")
# a("wen",10)

#__str__  __repr__
#__str__ 默认情况下调用的是repr  没有显示定义的话
#__str__是给用户看的
#__repr__是给程序开发者看的
# class A:
#     def __str__(self):
#         #print("i am str")
#         return "ok"
#
#     def __repr__(self):
#         return "repr ok"
# a = A()
# print(a)

# >>> class A:
# ...     def __str__(self):
# ...         return "ok"
# ...
# >>> a = A()
# >>> a
# <__main__.A object at 0x7fe39b9452b0>
# >>> print(a)
# ok
# >>> class A:
# ...     def __str__(self):
# ...         return "ok"
# ...     def __repr__(self):
# ...         return "repr"
# ...
# >>> a = A()
# >>> a
# repr
# >>> print(a)
# ok

# class B:
#     def __call__(self):
#         return "i am call"
#
# b = B()
# print(b())

#__getitem__
#__setitem__
#__delitem__
#像字典形式去获取或者设置参数
# class A:
#     def __init__(self):
#         self.data = {}
#     def __getitem__(self,key):
#         print("get data:")
#         return self.data[key]
#
#     def __setitem__(self, key, value):
#         print("set data:",key, value)
#         self.data[key] = value
#
#     def  __delitem__(self, key):
#         print("delete data")
#         del(self.data[key])
#
#     def show(self):
#         print(self.data)
#
#
# a = A()
# a["name"] = "wen"
# a["age"] = 18
# a["sex"] = "女"
# #a.show()
# print(a["age"])
# del a['age']
# a.show()
#print(a.get("age"))

# import smtplib
# from email.mime.multipart import MIMEMultipart
#
# #第三方smtp服务
# mail_host = "smtp.qq.com"
# mail_user = "343292019@qq.com"
# mail_pass = "xxxxx"
#
# #
# message = MIMEMultipart()
# message["From"] = mail_user
# message["To"] = "xxxx"

#__add__
class A:
    tmp = "tmp"
    def __init__(self,num):
        self.num = num
    def __add__(self,x):
        print("this is add")
        #return self.num+x
        #return "add test"
class B(A):
    pass
# a = A(1)
# b = a+2  #---> a.__add__(2)
# c = a.__add__(2)
# print(b, c)

#查看属性
a = A(1)
# print(dir(a))
# print(a.__dict__)
# print(A.__dict__)
print(A.__name__)
print(A.__module__)
# print(A.__bases__)
print(B.__bases__)


